<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Vector Template Library (Vtl): W:/Products/Vtl/branches/v1.0/Vtl/Vtl/include/Vtl/Polygon.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Vector Template Library (Vtl)
   &#160;<span id="projectnumber">v1.0</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_polygon_8h.html','');
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">W:/Products/Vtl/branches/v1.0/Vtl/Vtl/include/Vtl/Polygon.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_polygon_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#pragma once</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="comment">/* </span>
<a name="l00003"></a>00003 <span class="comment">* COPYRIGHT 2012 Mafahir Fairoze</span>
<a name="l00004"></a>00004 <span class="comment">* </span>
<a name="l00005"></a>00005 <span class="comment">* This file is part of Vector Template Library (Vtl) v1.0.</span>
<a name="l00006"></a>00006 <span class="comment">* (Project Website : http://mafahir.wordpress.com/projects/neuralplusplus)</span>
<a name="l00007"></a>00007 <span class="comment">* </span>
<a name="l00008"></a>00008 <span class="comment">* Vector Template Library (Vtl) v1.0 is a free software. You can redistribute it and/or modify it under the terms of</span>
<a name="l00009"></a>00009 <span class="comment">* the GNU General Public License as published by the Free Software Foundation, either version 3</span>
<a name="l00010"></a>00010 <span class="comment">* of the License, or (at your option) any later version.</span>
<a name="l00011"></a>00011 <span class="comment">* </span>
<a name="l00012"></a>00012 <span class="comment">* Vector Template Library (Vtl) v1.0 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;</span>
<a name="l00013"></a>00013 <span class="comment">* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span>
<a name="l00014"></a>00014 <span class="comment">* See the GNU General Public License &lt;http://www.gnu.org/licenses/&gt; for more details.</span>
<a name="l00015"></a>00015 <span class="comment">*/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#include &quot;<a class="code" href="eigen_8h.html">Vtl/eigen.h</a>&quot;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="_a_a_b_box_8h.html">Vtl/AABBox.h</a>&quot;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;Eigen/StdVector&gt;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="keyword">namespace </span>Vtl
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023         <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Scalar, <span class="keywordtype">int</span> Dimension&gt;
<a name="l00024"></a><a class="code" href="class_vtl_1_1_polygon.html">00024</a>         <span class="keyword">class </span><a class="code" href="class_vtl_1_1_polygon.html">Polygon</a>
<a name="l00025"></a>00025         {
<a name="l00026"></a>00026         <span class="keyword">public</span>:
<a name="l00027"></a><a class="code" href="class_vtl_1_1_polygon.html#a35005e3a8cafffabd284e551ad483896">00027</a>                 <span class="keyword">typedef</span> Eigen::Matrix&lt;Scalar, Dimension, 1&gt; <a class="code" href="class_vtl_1_1_polygon.html#a35005e3a8cafffabd284e551ad483896">VectorType</a>;
<a name="l00028"></a><a class="code" href="class_vtl_1_1_polygon.html#ae07188a6950d7e2e658edb5acc3e7193">00028</a>                 <span class="keyword">typedef</span> std::vector&lt;VectorType, Eigen::aligned_allocator&lt;VectorType&gt;&gt; <a class="code" href="class_vtl_1_1_polygon.html#ae07188a6950d7e2e658edb5acc3e7193">Container</a>;
<a name="l00029"></a><a class="code" href="class_vtl_1_1_polygon.html#a07b293eac6a4f84c25aa7d03154027ba">00029</a>                 <span class="keyword">typedef</span> <span class="keyword">typename</span> Container::size_type <a class="code" href="class_vtl_1_1_polygon.html#a07b293eac6a4f84c25aa7d03154027ba">size_type</a>;
<a name="l00030"></a><a class="code" href="class_vtl_1_1_polygon.html#aa640c9a07ee64411a5ffb715a17112b3">00030</a>                 <span class="keyword">typedef</span> Eigen::ParametrizedLine&lt;Scalar,Dimension&gt; <a class="code" href="class_vtl_1_1_polygon.html#aa640c9a07ee64411a5ffb715a17112b3">ParametrizedLine</a>;
<a name="l00031"></a><a class="code" href="class_vtl_1_1_polygon.html#a7d06f703bb987be44ac6fb65c3301105">00031</a>                 <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_a_a_b_box.html">AABBox&lt;double, Dimension&gt;</a> <a class="code" href="class_vtl_1_1_polygon.html#a7d06f703bb987be44ac6fb65c3301105">BoundingBox</a>;
<a name="l00032"></a>00032 
<a name="l00036"></a><a class="code" href="class_vtl_1_1_polygon.html#ab64f9123614fafbd12334108a6eb25b4">00036</a>                 <a class="code" href="class_vtl_1_1_polygon.html#ab64f9123614fafbd12334108a6eb25b4" title="Default constructor.">Polygon</a>(<span class="keywordtype">void</span>)
<a name="l00037"></a>00037                 {
<a name="l00038"></a>00038                 }
<a name="l00039"></a>00039 
<a name="l00045"></a><a class="code" href="class_vtl_1_1_polygon.html#a2dd95f5430e770ceed3b2d1417467f7b">00045</a>                 <a class="code" href="class_vtl_1_1_polygon.html#a35005e3a8cafffabd284e551ad483896">VectorType</a> &amp; <a class="code" href="class_vtl_1_1_polygon.html#a2dd95f5430e770ceed3b2d1417467f7b" title="Returns the vertex at index.">operator[]</a>(<span class="keyword">const</span> <a class="code" href="class_vtl_1_1_polygon.html#a07b293eac6a4f84c25aa7d03154027ba">size_type</a> &amp;_Index)
<a name="l00046"></a>00046                 {
<a name="l00047"></a>00047                         <span class="keywordflow">return</span> <a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>[_Index];
<a name="l00048"></a>00048                 }
<a name="l00049"></a>00049 
<a name="l00055"></a><a class="code" href="class_vtl_1_1_polygon.html#a574d4c229e9b5290e8efcbe99c456ce8">00055</a>                 <span class="keyword">const</span> <a class="code" href="class_vtl_1_1_polygon.html#a35005e3a8cafffabd284e551ad483896">VectorType</a> &amp; <a class="code" href="class_vtl_1_1_polygon.html#a2dd95f5430e770ceed3b2d1417467f7b" title="Returns the vertex at index.">operator[]</a>(<span class="keyword">const</span> <a class="code" href="class_vtl_1_1_polygon.html#a07b293eac6a4f84c25aa7d03154027ba">size_type</a> &amp;_Index)<span class="keyword"> const</span>
<a name="l00056"></a>00056 <span class="keyword">                </span>{
<a name="l00057"></a>00057                         <span class="keywordflow">return</span> <a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>[_Index];
<a name="l00058"></a>00058                 }
<a name="l00059"></a>00059 
<a name="l00064"></a><a class="code" href="class_vtl_1_1_polygon.html#a0abffd6f043fa7232f3c408725262234">00064</a>                 <span class="keywordtype">void</span> <a class="code" href="class_vtl_1_1_polygon.html#a0abffd6f043fa7232f3c408725262234" title="Appends another vertex into the polygon.">Append</a>(<span class="keyword">const</span> <a class="code" href="class_vtl_1_1_polygon.html#a35005e3a8cafffabd284e551ad483896">VectorType</a> &amp;_Vertice)
<a name="l00065"></a>00065                 {
<a name="l00066"></a>00066                         <a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>.push_back(_Vertice);
<a name="l00067"></a>00067                         <a class="code" href="class_vtl_1_1_polygon.html#a89ec4c72bc45f12e424859f6cebf9290">bounding_box</a>.<a class="code" href="class_vtl_1_1_a_a_b_box.html#a2d09608f6c2bd28481c114e71c5db402" title="Adds the point to expand bounding box. Only if the given point is outside, the bounding box shall exp...">AddInPoint</a>(_Vertice);
<a name="l00068"></a>00068                 }
<a name="l00069"></a>00069 
<a name="l00074"></a><a class="code" href="class_vtl_1_1_polygon.html#a365f08056e2072dde33bbfa552a5c505">00074</a>                 <a class="code" href="class_vtl_1_1_polygon.html#a07b293eac6a4f84c25aa7d03154027ba">size_type</a> <a class="code" href="class_vtl_1_1_polygon.html#a365f08056e2072dde33bbfa552a5c505" title="Returns the vertex count in the array.">getVertexCount</a>()<span class="keyword"> const</span>
<a name="l00075"></a>00075 <span class="keyword">                </span>{
<a name="l00076"></a>00076                         <span class="keywordflow">return</span> <a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>.size();
<a name="l00077"></a>00077                 }
<a name="l00078"></a>00078 
<a name="l00082"></a><a class="code" href="class_vtl_1_1_polygon.html#a2eee1cd5834d7c3a36891a892c4b1656">00082</a>                 <span class="keywordtype">void</span> <a class="code" href="class_vtl_1_1_polygon.html#a2eee1cd5834d7c3a36891a892c4b1656" title="Recalculates the bounding box for the existing set of vertices.">RecalculateBoundingBox</a>()
<a name="l00083"></a>00083                 {
<a name="l00084"></a>00084                         <a class="code" href="class_vtl_1_1_polygon.html#a89ec4c72bc45f12e424859f6cebf9290">bounding_box</a>.<a class="code" href="class_vtl_1_1_a_a_b_box.html#a28b1b7d5995f6e506bd77d829aa8a4f2" title="Resets the bounding box the given point. Sets the bounding box to NOT empty (initialized) state...">Reset</a>();
<a name="l00085"></a>00085                         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>.size();i++)
<a name="l00086"></a>00086                                 <a class="code" href="class_vtl_1_1_polygon.html#a89ec4c72bc45f12e424859f6cebf9290">bounding_box</a>.<a class="code" href="class_vtl_1_1_a_a_b_box.html#a2d09608f6c2bd28481c114e71c5db402" title="Adds the point to expand bounding box. Only if the given point is outside, the bounding box shall exp...">AddInPoint</a>(<a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>[i]);
<a name="l00087"></a>00087 
<a name="l00088"></a>00088                 }
<a name="l00089"></a>00089 
<a name="l00095"></a><a class="code" href="class_vtl_1_1_polygon.html#aedf8c62294cb6547c81544b5139d604d">00095</a>                 <span class="keyword">const</span> <a class="code" href="class_vtl_1_1_a_a_b_box.html">BoundingBox</a> &amp; <a class="code" href="class_vtl_1_1_polygon.html#aedf8c62294cb6547c81544b5139d604d" title="Returns the bounding box.">getBoundingBox</a>()
<a name="l00096"></a>00096                 {
<a name="l00097"></a>00097                         <span class="keywordflow">return</span> <a class="code" href="class_vtl_1_1_polygon.html#a89ec4c72bc45f12e424859f6cebf9290">bounding_box</a>;
<a name="l00098"></a>00098                 }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100         <span class="keyword">protected</span>:
<a name="l00101"></a><a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">00101</a>                 <a class="code" href="class_vtl_1_1_polygon.html#ae07188a6950d7e2e658edb5acc3e7193">Container</a> <a class="code" href="class_vtl_1_1_polygon.html#acbde4b884d85bedfb187f8473bae3c02">vertices</a>;
<a name="l00102"></a><a class="code" href="class_vtl_1_1_polygon.html#a89ec4c72bc45f12e424859f6cebf9290">00102</a>                 <a class="code" href="class_vtl_1_1_a_a_b_box.html">BoundingBox</a> <a class="code" href="class_vtl_1_1_polygon.html#a89ec4c72bc45f12e424859f6cebf9290">bounding_box</a>;
<a name="l00103"></a>00103         };
<a name="l00104"></a>00104 
<a name="l00105"></a><a class="code" href="namespace_vtl.html#a08de5ac913fb435d231a381137ba9a08">00105</a>         <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_polygon.html">Polygon&lt;double, 3&gt;</a> <a class="code" href="namespace_vtl.html#a08de5ac913fb435d231a381137ba9a08">Polygon3d</a>;
<a name="l00106"></a><a class="code" href="namespace_vtl.html#ae83da17b1f86c7b7599d91019672832a">00106</a>         <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_polygon.html">Polygon&lt;double, 2&gt;</a> <a class="code" href="namespace_vtl.html#ae83da17b1f86c7b7599d91019672832a">Polygon2d</a>;
<a name="l00107"></a><a class="code" href="namespace_vtl.html#a38afdbd5ecb54f40542612986d9e90ee">00107</a>         <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_polygon.html">Polygon&lt;float, 3&gt;</a> <a class="code" href="namespace_vtl.html#a38afdbd5ecb54f40542612986d9e90ee">Polygon3f</a>;
<a name="l00108"></a><a class="code" href="namespace_vtl.html#a591a43672fa32547021cb9b3602a950f">00108</a>         <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_polygon.html">Polygon&lt;float, 2&gt;</a> <a class="code" href="namespace_vtl.html#a591a43672fa32547021cb9b3602a950f">Polygon2f</a>;
<a name="l00109"></a><a class="code" href="namespace_vtl.html#a2865e1326c5e44bb04b5782aeac62e81">00109</a>         <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_polygon.html">Polygon&lt;int, 3&gt;</a> <a class="code" href="namespace_vtl.html#a2865e1326c5e44bb04b5782aeac62e81">Polygon3i</a>;
<a name="l00110"></a><a class="code" href="namespace_vtl.html#adda4d7ee474e7e8e5f89861e6d7df756">00110</a>         <span class="keyword">typedef</span> <a class="code" href="class_vtl_1_1_polygon.html">Polygon&lt;int, 2&gt;</a> <a class="code" href="namespace_vtl.html#adda4d7ee474e7e8e5f89861e6d7df756">Polygon2i</a>;
<a name="l00111"></a>00111 };
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_polygon_8h.html">Polygon.h</a>      </li>

    <li class="footer">Generated on Sun Apr 22 2012 14:58:32 for Vector Template Library (Vtl) by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.0 </li>
   </ul>
 </div>


</body>
</html>
